require 'InterpreterFactory.rb'

class FlightClient
  factory = InterpreterFactory.new()
    
  flightsInterpreter = factory.getFlightsInterpreter
  puts("TEG to AMS (on 2012-01-31 or 2012-01-30) with business seats available")
  begin
    routes = flightsInterpreter.from("TEG").to("AMS").on("2012-01-31").on("2012-01-30").filterBusiness().query()
  rescue Exception
    puts ("#{$!}" )
  end
  puts(routes)
  puts('')
  
  flightsInterpreter = factory.getFlightsInterpreter
  puts("SSH via LIS to VIE (on 2012-01-29 or 2012-01-30) with 20 available seats and cheapest first")
  begin
    routes = flightsInterpreter.from("SSH").to("LIS").to("VIE").on("2012-01-29").on("2012-01-30").sortCheapestFirst.seats(20).query
  rescue Exception
    puts ("#{$!}" )
  end
  puts(routes)
  puts('')
  
  flightsInterpreter = factory.getFlightsInterpreter
  puts("SSH via LIS to VIE (on 2012-01-31) with 2 available seats and First Class Seats available and fastest first")
  begin
    routes = flightsInterpreter.from("SSH").to("LIS").to('VIE').on("2012-01-31").filterFirstClass.sortFastestFirst.seats(2).query
  rescue Exception
    puts ("#{$!}" )
  end
  puts(routes)
  puts('')
end